﻿using mvcForum.Core.Interfaces.Data;
using System;
using System.Linq.Expressions;


namespace mvcForum.Core.Specifications {

	public static class GroupMemberSpecifications {

		public class SpecificUser : ISpecification<GroupMember> {
			private readonly ForumUser user;

			public SpecificUser(ForumUser user) {
				this.user = user;
			}

			public Expression<Func<GroupMember, Boolean>> IsSatisfied {
				get {
					return x => x.ForumUserId == user.Id;
				}
			}
		}

		public class SpecificGroup : ISpecification<GroupMember> {
			private readonly Group group;

			public SpecificGroup(Group group) {
				this.group = group;
			}

			public Expression<Func<GroupMember, Boolean>> IsSatisfied {
				get {
					return x => x.GroupId == group.Id;
				}
			}
		}

		public class SpecificUserAndGroup : ISpecification<GroupMember> {
			private readonly ForumUser user;
			private readonly Group group;

			public SpecificUserAndGroup(ForumUser user, Group group) {
				this.user = user;
				this.group = group;
			}

			public Expression<Func<GroupMember, Boolean>> IsSatisfied {
				get {
					return x => x.ForumUserId == user.Id && x.GroupId == group.Id;
				}
			}
		}
	}
}